home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.4 KB | 240 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSOMPtr.tpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSOMPTR_H
- #include "FWSOMPtr.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::FW_TSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TSOMPtr<TRep>::FW_TSOMPtr() :
- fRep(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::~FW_TSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TSOMPtr<TRep>::~FW_TSOMPtr()
- {
- FW_START_DESTRUCTOR
- delete fRep;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::FW_TSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TSOMPtr<TRep>::FW_TSOMPtr(Environment *ev, TRep* rep) :
- fRep(NULL)
- {
- SetRep(ev, rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::SetRep
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- void FW_TSOMPtr<TRep>::SetRep(Environment *, TRep* rep)
- {
- if (fRep != rep)
- {
- delete fRep;
- fRep = rep;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::operator new
- //----------------------------------------------------------------------------------------
-
- // [JEL]
- // This method is private, and I'd prefer to leave it undefined, but CodeWarrior seems
- // to complain when instantiating templates with undefined methods, even if the methods
- // aren't used.
-
- #ifndef __MRC__
- #if __MWERKS__ < 0x0800
-
- template<class TRep>
- void* FW_TSOMPtr<TRep>::operator new(size_t size)
- {
- FW_PRIV_ASSERT(false);
- return 0;
- }
-
- #endif
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::FW_TSOMPtr(const FW_TSOMPtr<TRep>& other)
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TSOMPtr<TRep>::FW_TSOMPtr(const FW_TSOMPtr<TRep>&)
- {
- // [jkp] MetroWerks wants this to be defined
- FW_PRIV_ASSERT(false);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_TSOMPtr<TRep>::operator=(const FW_TSOMPtr<TRep>& other)
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- void FW_TSOMPtr<TRep>::operator=(const FW_TSOMPtr<TRep>&)
- {
- // [jkp] MetroWerks wants this to be defined
- FW_PRIV_ASSERT(false);
- }
-
-
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr() :
- fRep(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::~FW_TCountedSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TCountedSOMPtr<TRep>::~FW_TCountedSOMPtr()
- {
- FW_START_DESTRUCTOR
- if (fRep != NULL)
- {
- FW_SOMEnvironment ev;
-
- if (fRep->Release(ev) == 0)
- delete fRep;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr(const FW_TCountedSOMPtr<TRep>& other) :
- fRep(other.fRep)
- {
- if (fRep != NULL)
- {
- FW_SOMEnvironment ev;
-
- fRep->Acquire(ev);
- }
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr(Environment *ev, const FW_TCountedSOMPtr<TRep>& other) :
- fRep(other.fRep)
- {
- if (fRep != NULL)
- fRep->Acquire(ev);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- FW_TCountedSOMPtr<TRep>::FW_TCountedSOMPtr(Environment *ev, TRep* rep) :
- fRep(rep)
- {
- if (fRep != NULL)
- fRep->Acquire(ev);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::operator=
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- void FW_TCountedSOMPtr<TRep>::operator=(TRep* rep)
- {
- FW_SOMEnvironment ev;
- SetRep(ev, rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::SetRep
- //----------------------------------------------------------------------------------------
-
- template<class TRep>
- void FW_TCountedSOMPtr<TRep>::SetRep(Environment *ev, TRep* rep)
- {
- if (fRep != rep)
- {
- if (fRep != NULL && fRep->Release(ev) == 0)
- delete fRep;
-
- fRep = rep;
-
- if (fRep != NULL)
- fRep->Acquire(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_TCountedSOMPtr<TRep>::operator new
- //----------------------------------------------------------------------------------------
-
- // [JEL]
- // This method is private, and I'd prefer to leave it undefined, but CodeWarrior seems
- // to complain when instantiating templates with undefined methods, even if the methods
- // aren't used.
-
- #ifndef __MRC__
- #if __MWERKS__ < 0x0800
-
- template<class TRep>
- void* FW_TCountedSOMPtr<TRep>::operator new(size_t size)
- {
- FW_PRIV_ASSERT(false);
- return 0;
- }
-
- #endif
- #endif
-
-